/*
 * @lc app=leetcode.cn id=2475 lang=golang
 *
 * [2475] 数组中不等三元组的数目
 */
package Solutions

// @lc code=start
func unequalTriplets(nums []int) int {
	mp := make(map[int]int, len(nums))
	for _, v := range nums {
		mp[v]++
	}
	if len(mp) < 3 {
		return 0
	}
	ans := 0
	for v1, count1 := range mp {
		for v2, count2 := range mp {
			if v1 == v2 {
				continue
			}
			for v3, count3 := range mp {
				if v2 == v3 || v3 == v1 {
					continue
				}
				ans += count1 * count2 * count3
			}
		}
	}
	return ans / 6
}

// @lc code=end
